package com.jwt.token.config;

import com.jwt.token.filter.SessionFilter;
import com.jwt.token.filter.SessionFilter2;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter;
@Configuration
public class ConfigurationFilter {
	@Bean
	public Filter SessionFilter(){
		return new SessionFilter();
	}

	@Bean
	public Filter SessionFilter2(){
		return new SessionFilter2();
	}


	@Bean
	public FilterRegistrationBean testFilterRegistration() {


		FilterRegistrationBean registration = new FilterRegistrationBean();

		registration.setFilter(SessionFilter());//添加过滤器

		registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径

		//registration.addInitParameter("name", "alue");//添加默认参数

		registration.setName("SessionFilter");//设置优先级

		registration.setOrder(1);//设置优先级

		return registration;

	}

	@Bean
	public FilterRegistrationBean testFilterRegistration2() {

		FilterRegistrationBean registration = new FilterRegistrationBean();

		registration.setFilter(SessionFilter2());//添加过滤器

		registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径

		//registration.addInitParameter("name", "alue");//添加默认参数

		registration.setName("SessionFilter2");//设置优先级

		registration.setOrder(2);//设置优先级

		return registration;

	}


}
